package com.ysp.summary.service.impl;

import com.ysp.summary.entity.Student;
import com.ysp.summary.mapper.StudentMapper;
import com.ysp.summary.service.StudentService;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Service
public class StudentServiceImpl implements StudentService {

    @Resource
    private StudentMapper studentMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<Student> getStudentList() {
        Example example = new Example(Student.class);
        example.createCriteria().andEqualTo("id",1);
        return studentMapper.selectByExample(example);
    }

    @Override
    @Cacheable(cacheNames = "student",key = "studentKey")
    public List<Student> selectStudent() {
        return studentMapper.selectStudent();
    }

    @Override
    public Student getStudent(long id) {
        return studentMapper.selectById(id);
    }
}
